import 'package:flutter/material.dart';
import 'package:get/get.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      theme: ThemeData(
        useMaterial3: false, // 禁用Material3样式
        primarySwatch: Colors.blue,
      ),
      home: const ContentPage(),
    );
  }
}

class ContentPage extends StatefulWidget {
  const ContentPage({super.key});

  @override
  State<ContentPage> createState() => _ContentPageState();
}

class _ContentPageState extends State<ContentPage> {
  final TextEditingController _textEditingController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('GetUtils')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Padding(
              padding: const EdgeInsets.all(20),
              child: TextField(
                controller: _textEditingController,
              ),
            ),
            ElevatedButton(
              onPressed: () {
                if (GetUtils.isEmail(_textEditingController.text)) {
                  Get.snackbar('正确', '输入内容正确！', backgroundColor: Colors.green);
                } else {
                  Get.snackbar('失败', '输入内容失败！', backgroundColor: Colors.red);
                }
              },
              child: const Text('验证邮箱'),
            )
          ],
        ),
      ),
    );
  }
}
